package com.zero.controller;

import com.zero.service.AdminService;
import com.zero.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping("/admin")
public class AdminController {

    @Autowired
    private AdminService adminService;

    /**
     * 获得登录的管理员信息
     * @param request
     * @return
     */
    @GetMapping("/info")
    public Result getAdminInfo(HttpServletRequest request){

        return adminService.getAdminInfo(request);
    }

    /**
     * 验证登录的管理员密码
     * @param password
     * @param request
     * @return
     */
    @GetMapping("/verifyPassword")
    public Result verifyPassword(@RequestParam("password") String password, HttpServletRequest request){
        return adminService.verifyPassword(password, request);
    }

    /**
     * 修改管理员密码
     * @param map
     * @param request
     * @return
     */
    @PostMapping("/updatePassword")
    public Result updatePassword(@RequestBody Map map, HttpServletRequest request){
        return adminService.updatePassword(map, request);
    }
}
